package com.mmc.sqlSession;

import com.mmc.container.Configration;
import com.mmc.sqlSession.xml.XmlConfigerBuilder;
import com.mmc.utils.Resources;
import org.dom4j.DocumentException;

import java.beans.PropertyVetoException;
import java.io.InputStream;

public class SqlSessionFactoryBuilder {

    public SqlSessionFactory builder(String path) throws DocumentException, PropertyVetoException, ClassNotFoundException {
        InputStream resourceAsStream = Resources.getResourceAsSteam(path);
        Configration configration = XmlConfigerBuilder.parseConfiguration(resourceAsStream);
        return new DefaultSqlSessionFactory(configration);
    }
}
